//
//  ShowOrderWinInfoCell.m
//  YunGou
//
//  Created by macbook on 16/6/24.
//  Copyright © 2016年 macbook. All rights reserved.
//

#import "ShowOrderWinInfoCell.h"
#import <UIImageView+WebCache.h>
#import "NSString+DateTransform.h"
#import "NSString+Frame.h"

@interface ShowOrderWinInfoCell ()

@property (weak, nonatomic) IBOutlet UIImageView *avaterImg;
@property (weak, nonatomic) IBOutlet UILabel *username;
@property (weak, nonatomic) IBOutlet UILabel *time;
@property (weak, nonatomic) IBOutlet UILabel *goodsname;
@property (weak, nonatomic) IBOutlet UILabel *qihao;
@property (weak, nonatomic) IBOutlet UILabel *canyurenci;
@property (weak, nonatomic) IBOutlet UILabel *showTime;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *heightConstraint;
@property (weak, nonatomic) IBOutlet UILabel *buyTime;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bgHeightConstraint;
@end

@implementation ShowOrderWinInfoCell

- (void)awakeFromNib {
    _avaterImg.layer.cornerRadius = _avaterImg.frame.size.width/2;
    _avaterImg.clipsToBounds = YES;
    // Initialization code
}

- (void)setOrderModel:(ShowOrderModel *)orderModel{
    [_avaterImg sd_setImageWithURL:[NSURL URLWithString:[ImageUrl stringByAppendingString:orderModel.img]]];
    _username.text = orderModel.username;
    _buyTime.text = [NSString timeTransformWithString:orderModel.q_end_time andFormatter:@"yyyy-MM-dd HH:mm:ss"];
    _showTime.text = [NSString timeTransformWithString:orderModel.q_end_time andFormatter:@"yyyy-MM-dd HH:mm:ss"];
    
    NSString *goodsName = [NSString stringWithFormat:@"获得奖品：%@",orderModel.title];
    _goodsname.text = goodsName;
    CGFloat height = [goodsName heightWithFont:[UIFont systemFontOfSize:12] withinWidth:ScreenWidth-48];
    _heightConstraint.constant = height;
    _qihao.text = [NSString stringWithFormat:@"商品期号：%@",orderModel.qishu];
    _canyurenci.text = [NSString stringWithFormat:@"参与人次：%ld",orderModel.canyurenshu];
    _bgHeightConstraint.constant = 85 - 14.5 + height;
}
- (IBAction)showDetailClicked:(id)sender {
    if (self.block) {
        self.block();
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
